<!doctype html>
<html>
<head>
	<meta charset="utf-8" />
	<title>Validation</title>
	<link rel="stylesheet" type="text/css"  href="../../../../kissy-dpl/base/build/css/dpl-pkg.css" />
	<script src="../../../build/kissy.js" charset="utf-8"></script>
	
	<link rel="stylesheet" type="text/css"  href="doc.css" /> <script src="doc.js" charset="utf-8"></script>
	<script type="text/javascript" src="../../../tools/utils/syntaxhighlighter_3.0.83/scripts/shCore.js"></script>
<script type="text/javascript" src="../../../tools/utils/syntaxhighlighter_3.0.83/scripts/shBrushJScript.js"></script>
<link type="text/css" rel="stylesheet" href="../../../tools/utils/syntaxhighlighter_3.0.83/styles/shCoreDefault.css"/>
<script type="text/javascript">SyntaxHighlighter.all();</script>

	

	
</head>
<body>
 

<div class="note">
<pre class="brush: js;">

	KISSY.use("validation",function(S,Validation){

			var form = S.query("form")[0],
			
				check = new Validation(form,{
					style: "under"
				});

			//实例化字段，配置通过参数传入
			var f = new Validation.Field("#username",{
				style:'under',
				chinese:['姓名只能是中文']
			})
	
			//增加到校验中
			check.add(f);


			KISSY.Event.on(form,"submit",function(){
				check.isValid();
				return false;
			});
		
	});
</pre>
</div>
 
<div id="viewdemo" class="doc">
	

<form method="post">
<ul class="form">

	<li>
		<label class="hd">姓名：</label>
        <p>如果不想通过伪属性配置，可以实例化Validation后用add方法增加要校验的字段</p>
		<input class="text" type="text" name="username" id="username"/>
	</li>
	
	<li>
		<button type="submit">提交</button> 
	</li>
	
</ul>
</form>

<script>



	KISSY.use("validation",function(S,Validation){

			var form = S.query("form")[0],
			
				check = new Validation(form,{
					style: "under"
				});

			//实例化字段，配置通过参数传入
			var f = new Validation.Field("#username",{
				style:'under',
				chinese:['姓名只能是中文']
			})
	
			//增加到校验中
			check.add(f);


			KISSY.Event.on(form,"submit",function(){
				check.isValid();
				return false;
			});
		
	});

</script>



</div>








</body>
</html>


















